package com.punai.apply.controller;

import com.punai.apply.domain.ApplyCostMouldDetails;
import com.punai.apply.service.IApplyCostMouldDetailsService;
import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.standard.domain.StaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 成本编制模板管理详情Controller
 * 
 * @author zhx
 * @date 2023-03-21
 */
@RestController
@RequestMapping("/apply/applyCostMouldDetails")
public class ApplyCostMouldDetailsController extends BaseController
{
    @Autowired
    private IApplyCostMouldDetailsService applyCostMouldDetailsService;

    /**
     * 查询成本编制模板管理详情列表
     */
    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplyCostMouldDetails applyCostMouldDetails)
    {
//        startPage();
        List<ApplyCostMouldDetails> list = applyCostMouldDetailsService.selectApplyCostMouldDetailsList(applyCostMouldDetails);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:list')")
    @GetMapping("/listVersion/{mouldId}")
    public TableDataInfo listVersion(@PathVariable("mouldId") String mouldId)
    {
//        startPage();
        List<StaVersion> list = applyCostMouldDetailsService.listVersion(mouldId,getCompanyId());
        return getDataTable(list);
    }

    /**
     * 获取成本编制模板管理详情详细信息
     */
//    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(applyCostMouldDetailsService.selectApplyCostMouldDetailsById(id));
    }

    /**
     * 新增成本编制模板管理详情
     */
//    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:add')")
    @Log(title = "成本编制模板管理详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplyCostMouldDetails applyCostMouldDetails)
    {
        return toAjax(applyCostMouldDetailsService.insertApplyCostMouldDetails(applyCostMouldDetails));
    }

    /**
     * 修改成本编制模板管理详情
     */
//    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:edit')")
    @Log(title = "成本编制模板管理详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplyCostMouldDetails applyCostMouldDetails)
    {
        return toAjax(applyCostMouldDetailsService.updateApplyCostMouldDetails(applyCostMouldDetails));
    }

    /**
     * 删除成本编制模板管理详情
     */
//    @PreAuthorize("@ss.hasPermi('apply:applyCostMouldDetails:remove')")
    @Log(title = "成本编制模板管理详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(applyCostMouldDetailsService.deleteApplyCostMouldDetailsByIds(ids));
    }
}
